//
//  RecognizeView.m
//  FaceRecognition
//
//  Created by zz on 16/12/1.
//  Copyright © 2016年 Sylar. All rights reserved.
//

#import "RecognizeView.h"


@interface RecognizeView()

/**识别照片文字label*/
@property (nonatomic,strong) UILabel *infoLabel;


@end

@implementation RecognizeView

- (instancetype)initWithFrame:(CGRect)frame{

    if (self = [super initWithFrame:frame]) {
        
        [self setupSubViewsWithFrame:frame];
    }
    
    return self;
}

- (void)setupSubViewsWithFrame:(CGRect)frame{
    
    CGFloat w = frame.size.width;
    
    _infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 12, 150, 12)];
    _infoLabel.font = [UIFont systemFontOfSize:12];
    _infoLabel.textColor = [UIColor colorWithHexString:@"#979797"];
    _infoLabel.text = @"识别照片";
    [self addSubview:_infoLabel];
    
    _specificationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _specificationBtn.contentHorizontalAlignment = NSTextAlignmentRight;
    [_specificationBtn setTitle:@"识别照片规范" forState:UIControlStateNormal];
    _specificationBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    [_specificationBtn setTitleColor:DEFAULTCOLOR forState:UIControlStateNormal];
    _specificationBtn.frame = CGRectMake(w - 15 - 100, 6, 100, 32);
    _specificationBtn.centerY = _infoLabel.centerY + 1.5;
    
    [self addSubview:_specificationBtn];
    
    CGFloat phX,phY,phW,phH; //照片的x,y,w,h
    
    phW = (w - 12 * 2 - 15 * 2) / 3;
    phH = phW;
    
    CGFloat maxY = CGRectGetMaxY(_infoLabel.frame) + 12;
    
    for (int i = 0; i < 3; i++) {
        
        phX = 15 + (i % 3) * (phW + 12);
        phY = maxY + (i / 3);
        
        _photoView = [[photoView alloc] initWithFrame:CGRectMake(phX, phY, phW, phH)];
        [self addSubview:_photoView];
        
        //设置tag
        _photoView.tag = 200 + i;
        
        if (i == 2) {
            
            maxY = CGRectGetMaxY(_photoView.frame);
        }
    }
    
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, maxY + 12, w, 10)];
    bgView.backgroundColor = [UIColor colorWithHexString:@"#F5F8FA"];
    [self addSubview:bgView];
}



@end
